package com.tuliomoura.got.guide;

import android.app.Application;
import android.content.res.AssetManager;
import android.graphics.Typeface;

import com.tuliomoura.got.guide.globals.FontsEnum;

public class GuideApplication extends Application
{
	public static final String PREFERRED_FONT = "preferredFont";
	private static AssetManager mAssetManager;
	
	public void onCreate()
	{
		super.onCreate();
		mAssetManager = getAssets();
	}
	
	public static Typeface getFontByFontsEnum(FontsEnum font)
	{
		if (font == FontsEnum.ANIRON)
		{
			if (Fonts.ANIRON == null)
				Fonts.ANIRON = Typeface.createFromAsset(mAssetManager, "fonts/aniron.ttf");
			return Fonts.ANIRON;
		}
		if (font == FontsEnum.BLACK_KNIGHT)
		{
			if (Fonts.BLACK_KNIGHT == null)
				Fonts.BLACK_KNIGHT = Typeface.createFromAsset(mAssetManager, "fonts/blackKnight.ttf");
			return Fonts.BLACK_KNIGHT;
		}
		if (font == FontsEnum.CRUSADES)
		{
			if (Fonts.CRUSADES == null)
				Fonts.CRUSADES = Typeface.createFromAsset(mAssetManager, "fonts/crusades.ttf");
			return Fonts.CRUSADES;
		}
		if (font == FontsEnum.ENGLISH_TOWNE)
		{
			if (Fonts.ENGLISH_TOWNE == null)
				Fonts.ENGLISH_TOWNE = Typeface.createFromAsset(mAssetManager, "fonts/englishTowne.ttf");
			return Fonts.ENGLISH_TOWNE;
		}
		if (font == FontsEnum.FREDERICK_TEXT)
		{
			if (Fonts.FREDERICK_TEXT == null)
				Fonts.FREDERICK_TEXT = Typeface.createFromAsset(mAssetManager, "fonts/frederickText.ttf");
			return Fonts.FREDERICK_TEXT;
		}
		if (font == FontsEnum.LOHENGRIN)
		{
			if (Fonts.LOHENGRIN == null)
				Fonts.LOHENGRIN = Typeface.createFromAsset(mAssetManager, "fonts/lohengrin.ttf");
			return Fonts.LOHENGRIN;
		}
		if (font == FontsEnum.OLD_LONDON)
		{
			if (Fonts.OLD_LONDON == null)
				Fonts.OLD_LONDON = Typeface.createFromAsset(mAssetManager, "fonts/oldLondon.ttf");
			return Fonts.OLD_LONDON;
		}
		if (font == FontsEnum.PRINCE_VALIANT)
		{
			if (Fonts.PRINCE_VALIANT == null)
				Fonts.PRINCE_VALIANT = Typeface.createFromAsset(mAssetManager, "fonts/princeValiant.ttf");
			return Fonts.PRINCE_VALIANT;
		}
		if (font == FontsEnum.WEST_MINSTER)
		{
			if (Fonts.WEST_MINSTER == null)
				Fonts.WEST_MINSTER = Typeface.createFromAsset(mAssetManager, "fonts/westminster.ttf");
			return Fonts.WEST_MINSTER;
		}
		return Typeface.SERIF;
	}
	
    private static class Fonts
    {
    	public static Typeface ANIRON;
    	public static Typeface BLACK_KNIGHT;
    	public static Typeface CRUSADES;
    	public static Typeface ENGLISH_TOWNE;
    	public static Typeface FREDERICK_TEXT;
    	public static Typeface LOHENGRIN;
    	public static Typeface OLD_LONDON;
    	public static Typeface PRINCE_VALIANT;
    	public static Typeface WEST_MINSTER;
    }
}
